﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace GL_CommonPrint
{
    internal static class FilePath
    {
        static string excelTemplateFolderName = "ExcelTemplates";
        static string pdfFolderName = "PDFs";
        //string finishExcelFolderName = "Finishes";

        public enum GL_FileType
        {
            TemplateExcel,
            PDF,
            FinishExcel
        }

        internal static string getFolderPath(string folderName)
        {
            //HttpContext.Current.Server.MapPath("~/Photos/");

            //var currentDirectory = Directory.GetCurrentDirectory();

            //var IsExcelFolderExist = Directory.Exists(folderName);

            //if (!IsExcelFolderExist)
            //{
            //    Directory.CreateDirectory(folderName);
            //}

            //var excelFolder = currentDirectory + "\\" + folderName;

            var path = HttpContext.Current.Server.MapPath("~/" + folderName + "/");
            var IsExcelFolderExist = Directory.Exists(path);
            if (!IsExcelFolderExist)
            {
                Directory.CreateDirectory(path);
            }

            return path;
        }

        internal static string getFullPath(GL_FileType type, string fileName)
        {
            var folderPath = "";
            switch (type)
            {
                case GL_FileType.TemplateExcel:
                    folderPath = getFolderPath(excelTemplateFolderName);
                    break;
                case GL_FileType.PDF:
                    folderPath = getFolderPath(pdfFolderName);
                    break;
                    //case FileType.FinishExcel:
                    //    folderPath = getFolderPath(finishExcelFolderName);
                    //    break;
            }

            return folderPath + "\\" + fileName;
        }
    }
}
